@extends('admin.layouts.master')
@section('css')
    <style>
        /*master引入后显示==会员管理*/
        .order_manage{
            background: #393F64;
        }
        /*搜索框所在的区域*/
        .main_header{
            float: left;
            margin-top: 8px;
            width:100%;
            height: 100px;
            line-height: 100px;

        }
        .main_header_search{
            float: left;
            width: 155px;
            position: relative;
        }
        .main_header_search input{
            border-radius:6px;
            width: 215px;
            height: 40px;
            margin-top: 30px;
            border: 0px solid;
        }
        /*.main_header_search input:hover{*/
            /*box-shadow: 0 8px 12px rgba(0,0,0,0.2);*/
        /*}*/

        /*.main_header_search input{*/
            /*padding-left:45px;*/
            /*font-size: 16px;*/
            /*color:#ccc;*/
        /*}*/
        /*================*/
        .main_header_add{
            float: right;
            width: 215px;
            height: 100px;
            line-height: 100px;
            text-align: right;

        }
        .add_box {
            float: right;
            width: 90px;
            height: 40px;
            margin-top: 32px;
            background: #fff;
            line-height: 40px;
            cursor: pointer;
            border-radius: 6px;
            margin-left:17px;
        }
        .add_box:hover{
            box-shadow: 0 8px 12px rgba(0,0,0,0.2);
        }

        .add_box img{
            float:left;
            margin-top:6px;
            margin-left:6px;
            width: 28px;
            height: 28px;
            line-height: 40px;
        }
        .add_box span{
            float: left;
            font-size:18px;
            margin-left: 8px;
            color:  #24a7f6;
        }
        /*======主要内容区=====*/
        .main_form{
            float: left;
            width: 100%;
            height: 783px;
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 8px 12px rgba(0,0,0,0.2);
        }
        .main_formlist{
            margin-top:30px;
        }
        .main_table{
            width: 94%;
            margin: 0 auto;
            border: 1px solid #B1B1B1;
        }
        .main_table tr{
            height: 15px;
            width: 100%;
        }
        .main_table tr th{
            text-align: center;
            line-height: 20px;
            height: 20px;
            font-size: 18px;
        }
        .main_table tr td{
            text-align: center;
        }
          /*======操作中的编辑与删除的样式======*/
        .formlist_handle a{
            font-size:18px;
            text-decoration: none;
        }
        .formlist_handle span{
            font-size:18px;
            cursor: pointer;
        }
        .formlist_edit{
            color: #79C9F7;
        }
        .formlist_destory{
            color: red;
        }

        /*laravel自带的分页样式*/
        .boot_fenye{
            margin: 0 auto;
            margin-top:2px;
            width: 94%;
            height: 55px;
        }
        .boot_page{
            float: right;

        }
        .boot_page_di{
            margin-left: 10px;
            float: left;
            text-align: right;
            font-size: 14px;
            height: 74px;
            line-height: 74px;

        }
        .boot_page_di_span{
            width: 34px;
            height: 34px;
            border: 1px solid #D6D6D1;
        }
        .boot_page_total{
            margin-left: 10px;
            float:left;
            text-align: right;
            font-size: 14px;
            height: 74px;
            line-height: 74px;


        }
        .boot_choose{
            margin-left:20px;
            float:right;
        }

    </style>
@endsection
@section('content')

    <div class="main_header clearfix">

        <div class="main_header_search clearfix">
            <form action="{{url('admin/order/')}}" method="post">
                {{csrf_field()}}
                <div class="input-group input_style"  style="width:200px;">
                    <input type="text" class="form-control" placeholder="输入订单号或者用户" value="{{$name or ''}}" name="username" style="height: 40px; "/>
                    <span class="input-group-btn">
                <button type="submit" class="btn btn-info btn-search glyphicon glyphicon-search" style="margin-top:-3px;background: #3FB2F7;height: 40px; "></button>
               </span>
                </div>
            </form>
        </div>
    </div>
    <div  class="main_form clearfix">
        <!-- 表格 -->
        <div class="main_formlist">
            <table class="table table-bordered main_table">
                <tbody>
                <tr>
                    <th>店铺名称</th>
                    <th>总价</th>
                    <th>订单号</th>
                    <th>下单时间</th>
                    <th>下单用户</th>
                    <th>操作</th>
                </tr>
                @foreach($orders as $order)
                <tr>
                    <td>{{$order->shop_name}}</td>
                    <td>{{$order->total}}元</td>
                    <td>{{$order->order_num}}</td>
                    <td>{{$order->created_at}}</td>
                    <td>{{$order->name}}</td>
                    <td>
                        {{--orders_id="{{$order->id}}--}}
                        <span class="formlist_handle">
                              @if(Auth::guard('admin')->user()->checkPermission('order.list'))
                           <a href="{{url('/admin/order/show',['orders_id'=>$order->id])}}" class="formlist_edit">
                               查看</a>
                            @endif
                                  @if(Auth::guard('admin')->user()->checkPermission('order.status'))
                              <span   class="formlist_destory change"
                                is_show="{{$order->is_active}}" data-id="{{$order->id}}" >
                                删除</span>
                           </span>
                        @endif
                    </td>
                </tr>
                @endforeach
                </tbody>

            </table>
        </div>
        <div class="boot_fenye">
            <div class="boot_page">
                <div class="boot_page_di">第<span class="">{{ $page = isset($_GET['page'])?$_GET['page']:1}}</span>页
                </div>
                <div  class="boot_page_total">共<span>{{$total_page}}</span>页
                </div>
            <div class="boot_choose">
                {{ $orders->appends(['name'=>$name])->render() }}
            </div>
        </div>

    </div>
@endsection
@section('js')
    <script type="text/javascript">
        $(".change").click(function () {
            var is_show = $(this).attr('is_show');
            var mythis = $(this);
            var id = $(this).data("id");
            if(confirm("确定要删除吗?")){
                $.ajax({
                    url: '/admin/order/status' ,
                    type:'post',
                    data: {'is_show': is_show,'id':id},
                    success: function (data) {
                        location.reload();
                        layer.msg("删除成功");
                    }
                });
            }

        });
    </script>
@endsection


